#include <stdio.h>
#include "ofc/DObjcTokenizer.h"
#include "ofc/DFile.h"

int main(int argc, char *argv[])
{
  DObjcTokenizer *src  = [DObjcTokenizer new];
  DFile          *file = [DFile          new];

  if ([file open :"DObjcTokenizer_exp.m" :"r"])
  {
    if ([src source :file :"DObjcTokenizer_exp.m"])
    {
      [src skipWhiteSpace :YES];       // Set: skip whitespace

      while (![src isEof])
      {
        int token = [src nextToken];   // Scan all tokens in the file

        if ([DObjcTokenizer isLogicalOperator :token])
        {
          printf("Logical operator: %s\n", [src text]);
        }
        else if ([DObjcTokenizer isComparisonOperator :token])
        {
          printf("Comparison operator: %s\n", [src text]);
        }
        else if ([DObjcTokenizer isBitOperator :token])
        {
          printf("Bit operator:%s\n", [src text]);
        }
        else if ([DObjcTokenizer isAssignmentOperator :token])
        {
          printf("Assignment operator:%s\n", [src text]);
        }
        else if ([DObjcTokenizer isArithmeticOperator :token])
        {
          printf("Arithmetic operator:%s\n", [src text]);
        }
        else if ([DObjcTokenizer isOperator :token])
        {
          printf("Operator:%s\n", [src text]);
        }
        else if ([DObjcTokenizer isPredefinedTypeKeyword :token])
        {
          printf("Predefined type:%s\n", [src text]);
        }
        else if ([DObjcTokenizer isStorageKeyword :token])
        {
          printf("Storage:%s\n", [src text]);
        }
        else if ([DObjcTokenizer isTypeDefinitionKeyword :token])
        {
          printf("Typedefinition:%s\n", [src text]);
        }
        else if ([DObjcTokenizer isFlowKeyword :token])
        {
          printf("Flow keyword:%s\n", [src text]);
        }
        else if ([DObjcTokenizer isObjcKeyword :token])
        {
          printf("Objc-keyword:%s\n", [src text]);
        }
        else if ([DObjcTokenizer isDirective :token])
        {
          printf("Directive:%s\n", [src text]);
        }
        else
          printf("Token:%d Text:%s\n", token, [src text]);
      }
    }
    else
      printf("File \"DObjcTokenizer_exp.m\" could not be used for the objc-tokenizer.\n");

    [file close];
  }
  else
    printf("File \"DObjcTokenizer_exp.m\" could not be opened:%d.\n", [file error]);

  [file free];                         // Cleanup
  [src  free];

  return 0;
}

